package cn.ppool.test.function.dao;

import cn.ppool.test.function.entity.UsersPO;
import cn.ppool.xmlmapper.builder.annotation.Select;

import java.util.List;
import java.util.Map;

public interface UsersDao {

    @Select(sql = "select * from users")
    List<UsersPO> findListByAnnotation();

    @Select(sql = "select * from users")
    List<Map<String, Object>> findLMapByAnnotation();

    @Select(sql = "select * from users where account=:{name}")
    UsersPO getBeanByAnnotation(String name);

    @Select(redirectTo = "getBeanByAnnotation")
    UsersPO redirectGetBeanByAnnotation(String name);

    @Select(sql = "select * from users where account=:{name}")
    Map<String, Object> getMapByAnnotation(String name);

    @Select(sql = "select COUNT(*) from users")
    int getAllUsersCount();

    @Select(sql = "select COUNT(*) alias_column_name from users")
    int getAllUsersAliasCount();

    @Select(sql = "select COUNT(*) from users where account in (:{accounts})")
    int getUsersCount(List<String> accounts);


    @Select(sql = "select * from users where account like #{merge(\"'\",'%',account,'%',\"'\")}")
    List<UsersPO> StringMerge(String account);

    @Select(sql = "select * from Users where account like '#{account.toLike()}'")
    List<UsersPO> StringToLike(String account);

    @Select(sql = "select * from Users where account = #{account.toSql()}")
    UsersPO StringToSql(String account);

    @Select(sql = "select * from Users where account = :{nvl(emptyAccount,account)}")
    UsersPO nvlString(String emptyAccount, String account);


    @Select(sql = "select * from Users where account like #{account.toLikeSql()}")
    List<UsersPO> toLikeSql(String account);

    List<UsersPO> multipleElse(String account);

    List<UsersPO> ifNullEmpty(String account);

    List<UsersPO> ifNotNullEmpty(String a1, String a2);

    List<UsersPO> ifMultipleTestVriable(String a1, String a2);

    UsersPO multipleCondition(String a1, String a2);

    UsersPO decodeSelect(String a1);

    UsersPO multipleConditionBreak(String a1, String a2, String b1, String b2);


}
